
#include "uthread.h"
#include "linked.h"
#include "queue.h"
#include <stdlib.h>
#include <stdio.h>

uthread_mutex_t mutex;
void testB(int p)
{
    printf("uthread exits\n");
    uthread_mutex_lock(&mutex);
    printf("this should never print\n");
    uthread_exit(); 
}

void testA(int c)
{
    uthread_create(&testB, 0, 8); 
    
    uthread_mutex_lock(&mutex);
    for(;;);
    
    uthread_exit();
}

int main()
{
 
    uthread_mutex_init(&mutex);
    printf("Calling init\n");
    uthread_init();
    printf("Creating testA's thread\n");
    uthread_create(&testA, 4, 8);
    printf("main yields\n");
    uthread_yield(); 
    printf("main exits\n");
    uthread_exit();
    printf("----->this should not print!\n");
    return 0;
}
